package com.hw.job_5;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

// 扑克牌类
public class Poker implements Comparable<Poker> {

    private static String[] numerArr = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
    private static String[] godArr = {"小王", "大王"};
    private static String[] colorArr = {"黑桃", "红桃", "梅花", "方块"};
    private static HashMap<String, Integer> cardNumMap = new HashMap<String, Integer>(){{
        put("1",1);
        put("2",2);
        put("3",3);
        put("4",4);
        put("5",5);
        put("6",6);
        put("7",7);
        put("8",8);
        put("9",9);
        put("10",10);
        put("J",11);
        put("Q",12);
        put("K",13);
        put("小王",100);
        put("大王",101);
    }};

    private String number;
    private String color;

    public Poker() {
    }

    public Poker(String number) {
        this.number = number;
    }

    public Poker(String number, String color) {
        this.number = number;
        this.color = color;
    }

    public String getNumber() {
        return number;
    }

    private void setNumber(String number) {
        this.number = number;
    }

    @Override
    public String toString() {
        return "Poker{" +
                "number='" + number + '\'' +
                ", color='" + color + '\'' +
                '}';
    }

    // 返回扑克牌组
    public static List<Poker> createPokeGroup() {
        // 制作扑克牌
        List<Poker> pokerGroup = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < numerArr.length; j++) {
                Poker poker = new Poker(numerArr[j], colorArr[i]);
                pokerGroup.add(poker);
            }
        }
        // 大王小王
        for (int i = 0; i < godArr.length; i++) {
            Poker poker = new Poker(godArr[i]);
            pokerGroup.add(poker);
        }
        return pokerGroup;
    }

    @Override
    public int compareTo(Poker o) {
        return Poker.cardNumMap.get(o.number) - Poker.cardNumMap.get(this.number);
    }
}
